package com.shengqi.xinnongren.work.ui.home.presenter;

import com.shengqi.xinnongren.common.base.BasePresenter;
import com.shengqi.xinnongren.common.config.network.Constants;
import com.shengqi.xinnongren.common.config.network.RetrofitHelper;
import com.shengqi.xinnongren.work.ui.home.view.StoreDetailsView;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class StoreDetailsPresenter extends BasePresenter<StoreDetailsView> {
    public void getStoreDetail(String storeId,String longt,String lat) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", storeId);
        map.put("x", longt);
        map.put("y", lat);
        JSONObject jsonData = Constants.getJsonData(map, null);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonData.toString());
        addTask(RetrofitHelper.getInstance().getService().getStoreDetail(requestBody), response -> getView().showStoreDetail(response));
    }
}
